package com.fenxiangle.yueding.feature.mine.view;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.widget.TextView;

import com.fenxiangle.yueding.R;
import com.fenxiangle.yueding.feature.login.view.LoginActivity;
import com.fenxiangle.yueding.feature.login.view.RecommendPeopleActivity;
import com.suozhang.framework.framework.AM;
import com.suozhang.framework.framework.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class SeetingActivity extends BaseActivity {


    @BindView(R.id.toolbar)
    Toolbar mToolbar;
    @BindView(R.id.btn_setting_logout)
    TextView mBtnSettingLogout;
    private String mBindId;
    private int timeValue;
    private String mName;
    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_setting;
    }

    @Override
    protected void initInjector() {

    }

    @Override
    protected void initView() {
        initToolBar(mToolbar, "设置", true, true);
    }

    @Override
    protected void initData() {
        mBindId = this.getIntent().getStringExtra("id");
        mName= this.getIntent().getStringExtra("name");
        timeValue = this.getIntent().getIntExtra("time_value", 0);
    }

    @OnClick(R.id.btn_setting_logout)
    public void onViewClicked() {
        if (AM.user().isLogin()) {
            AM.user().loginOut();
        }
        Intent outIntent = new Intent(this,
                LoginActivity.class);
        outIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK
                | Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(outIntent);
        finish();
    }


    @OnClick(R.id.btn_invoted)
    public void onVsiewClicked() {
        if (TextUtils.isEmpty(mBindId)) {
            Intent intent = new Intent(this, RecommendPeopleActivity.class);
            intent.putExtra("user_uid", AM.user().getLoginResultCache().getUserUid());
            startActivity(intent);
            finish();
        } else {
            Intent intent = new Intent(this, BindRecommendSuccessActivity.class);
            intent.putExtra("recommend_id", mBindId);
            startActivity(intent);
            finish();
        }

    }


    @OnClick(R.id.btn_edit_value)
    public void onViewEditClicked() {
        Intent intent = new Intent(this, EditTimeActivity.class);
        intent.putExtra("time_value", timeValue);
        startActivity(intent);
        finish();
    }


    @OnClick(R.id.btn_edit_nick)
    public void onViewddClicked() {
        Intent intents = new Intent(this, EditNickActivity.class);
        intents.putExtra("name", mName);
        startActivity(intents);
    }
}
